package top.xiequanquan.demo.swagger.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Size;

@RestController
@RequestMapping("/index")
@Api(value = "首页")
public class IndexController {


    @RequestMapping(value = "info", method = RequestMethod.GET)
    @ApiModelProperty(value = "用户名", required = true)
    @Size(min = 3, max = 10, message = "用户名长度必须位：3~10")
    public String info(String name) {
        return "hello world " + name;
    }

    @RequestMapping(value = "info/{name}", method = RequestMethod.GET)
    @ApiModelProperty(value = "用户名", required = true)
    @Size(min = 3, max = 10, message = "用户名长度必须位：3~10")
    public String infoTwo(@PathVariable("name") String name) {
        return "hello world " + name;
    }

    @RequestMapping(value = "save", method = RequestMethod.POST)
    public String save(String name) {
        return "保存成功：" + name;
    }
}
